package com.pointlion.sys.mvc.common.model;

import com.jfinal.aop.Before;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.plugin.activerecord.tx.Tx;
import com.pointlion.sys.mvc.common.model.base.BaseOaBusiness;
@SuppressWarnings("serial")
public class OaBusiness extends BaseOaBusiness<OaBusiness> {
	public static final OaBusiness dao = new OaBusiness();
	
	/***
	 * 根据主键查询
	 */
	public OaBusiness getById(String id){
		return OaBusiness.dao.findById(id);
	}
	
	/***
	 * 获取分页
	 */
	public Page<Record> getPage(int pnum,int psize, String userId){
		return Db.paginate(pnum, psize, " select b.*,p.PROC_DEF_ID_ defid", " from oa_business b LEFT JOIN act_hi_procinst p ON b.proc_ins_id=p.ID_ where b.sender_id = '"+userId+"' ORDER BY create_time DESC");
	}
	/***
	 * 删除
	 * @param ids
	 */
	@Before(Tx.class)
	public void deleteByIds(String ids){
    	String idarr[] = ids.split(",");
    	for(String id : idarr){
    		OaBusiness o = OaBusiness.dao.getById(id);
    		o.delete();
    	}
	}
	
}